﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace GameLibrary
{
    public abstract class DynamicElement : StaticElement
    {
        #region Public Properties
        public PointF Velocity { get; set; }
        public PointF Acceleration { get; set; }
        #endregion

        #region Constructor(s)
        public DynamicElement(GamePanel owningGame, PointF position, SizeF size, PointF velocity, PointF acceleration)
            : base(owningGame, position, size)
        {
            this.Velocity = velocity;
            this.Acceleration = acceleration;
        }

        public DynamicElement(GamePanel owningGame, RectangleF rectangle, PointF velocity, PointF acceleration)
            : base(owningGame, rectangle)
        {
            this.Velocity = velocity;
            this.Acceleration = acceleration;
        }
        #endregion

        #region Public Methods
        public PointF CalculateNextPosition(TimeSpan elapsedTime)
        {
            return 
                new PointF(
                    this.Rectangle.X + (float)elapsedTime.TotalSeconds * this.Velocity.X,
                    this.Rectangle.Y + (float)elapsedTime.TotalSeconds * this.Velocity.Y
                );
        }

        public PointF CalculateNextVelocity(TimeSpan elapsedTime)
        {
            return
                new PointF(
                    this.Velocity.X + (float)elapsedTime.TotalSeconds * this.Acceleration.X,
                    this.Velocity.Y + (float)elapsedTime.TotalSeconds * this.Acceleration.Y
                );
        }
        #endregion
    }
}
